import Taro, { Component } from '@tarojs/taro'
import { View, Text, Picker,Image ,Input} from '@tarojs/components'
import './quicklyFoundModify.css'
import { AtAvatar, AtList, AtListItem, AtInput, AtForm, AtButton, AtGrid,AtSearchBar,AtTag } from "taro-ui"
import app from '../../main';


export default class QuicklyFound extends Component {

  config = {
    navigationBarTitleText: '快速咨询'
  }
  constructor () { 
    super(...arguments); 
    this.state = {
        doctor_id: !this.$router.doctor_id ? '' : this.$router.doctor_id,
        text:'font-size: 14px ; color:#6d6d6d;' ,
        patients:[],

        //imgs
        jiantou: 'https://zhongsheng.bayou-tech.cn/img/imgs/jiantougai.png',
        jiahao: 'https://zhongsheng.bayou-tech.cn/img/imgs/jiahao.png',
        xinfeng: 'https://zhongsheng.bayou-tech.cn/img/imgs/xinfeng.png',
        zhengque: 'https://zhongsheng.bayou-tech.cn/img/imgs/zhengque.png',
        tianxie: 'https://zhongsheng.bayou-tech.cn/img/imgs/tianxie.png',       
    }
  }

  //跳转到填写患者信息
  gotoPatientInformation(){
	  app.navigateTo('../patientInformation/patientInformation?from=订单') 
  }

  //跳转填写病情
  gotoQuicklyConsultation(id,name){
    app.dingdanid = id
    app.dingdanname = name
    app.navigateTo('../quicklyConsultationModify/quicklyConsultationModify?id=' + '20')
  }

  //get 患者
  get(){
    let me = this;
    let data = {
        offset: 0,
        length: 99,
    }
    app.post('web/healthArchives/healthArchivesList', data, function(res) {
        console.log(res)
        let list = res.data.result.list
        let arr = []
        for(let i=0; i<list.length; i++){
            arr.push(list[i])
        }
        console.log(arr)
        me.setState({
            patients:arr
        })
    })
  }

  init() {
      this.get();
      app.doctorid = this.state.doctor_id;
  }

  componentDidShow(){
      this.init();
  }

  render () {
    return (
      <View className='index'>

        <View className='textBox'>
            <View className='select'>请选择咨询的患者</View>
            <View className='message'>请提供准确的信息以使医生做出更准确的指导,信息仅医生可见</View>
        </View>

        <View className='bodyBox'>
            {
                this.state.patients.map((item) =>{
                    return(
                        <View className='leftBox' onClick={this.gotoQuicklyConsultation.bind(this,item.id,item.name)}>
                            <View className='name'>{item.name}</View>
                            <View className='age'>{item.gender}ㅤ{item.age}岁</View>
                        </View>
                    )
                })
            }
            
            <View className='rightBox'onClick={this.gotoPatientInformation.bind(this)}>
                <Image className='addicon' src={this.state.jiahao}/>
                <View className='add'>添加患者</View>
            </View>
        </View>

      </View>
    )
  }
}
